<!--********************************************************************
* Copyright© 2000 - 2018 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title data-i18n="resources.title_windmap"></title>
    <style type="text/css">
        .editPane {
            position: absolute;
            right: 60px;
            top: 50px;
            text-align: center;
            background: #FFF;
            z-index: 1000;
        }
    </style>
</head>
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
<div class='panel panel-primary editPane' id='editPane' style="z-index: 99999">
    <div class='panel-heading'>
        <h5 class='panel-title text-center' data-i18n="resources.text_windmap"></h5>
    </div>
    <div class='panel-body' id='params'>
        <p></p>
        <div align='right' class='button-group'>
            <input type='button' id='btn1' class='btn btn-primary' data-i18n="[value]resources.btn_createWindRose" onclick="addWindMap()"/>
            <input type='button' id='btn2' class='btn btn-primary' data-i18n="[value]resources.btn_pause"  onclick="stop()"/>
            <input type='button' id='btn3' class='btn btn-primary' data-i18n="[value]resources.btn_run"  onclick="run()"/>
            <input type='button' id='btn4' class='btn btn-primary' data-i18n="[value]resources.text_input_value_delete" onclick="clear1()"/>
        </div>
    </div>
</div>

<div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
<script type="text/javascript" include="bootstrap,widgets.alert" src="../js/include-web.js"></script>
<script type="text/javascript" exclude="iclient-classic" include="D3WindMap,d3" src="../../dist/classic/include-classic.js"></script>
<script src='../data/windData1.js'></script>
<script src='../data/windData2.js'></script>
<script type="text/javascript">
    var map, baseLayer, elementsLayer, windData, myD3WindMap,
        host = window.isLocal ? window.server : "http://support.supermap.com.cn:8090",
        url = host + "/iserver/services/map-world/rest/maps/World";
    function init() {
        if (!hasSVG()) {
            widgets.alert.showAlert(resources.msg_supportSVG, false);
            return;
        }
        map = new SuperMap.Map("map", {
            controls: [
                new SuperMap.Control.ScaleLine(),
                new SuperMap.Control.Zoom(),
                new SuperMap.Control.Navigation({
                    dragPanOptions: {
                        enableKinetic: true
                    }
                })], allOverlays: true
        });
        baseLayer = new SuperMap.Layer.TiledDynamicRESTLayer("China400", url, {
            transparent: true,
            cacheEnabled: true
        }, {maxResolution: "auto"});
        baseLayer.events.on({"layerInitialized": addLayer});
    }
    $(document).ready(function () {
        init();
    });
    function hasSVG() {
        var doc = document;
        var SVG_NS = 'http://www.w3.org/2000/svg';
        return !!doc.createElementNS && !!doc.createElementNS(SVG_NS, 'svg').createSVGRect;
    }

    function addLayer() {
        elementsLayer = new SuperMap.Layer.Elements("elementsLayer");
        map.addLayers([baseLayer, elementsLayer]);
        map.setCenter(new SuperMap.LonLat(0, 0), 0);

        setData();
        myD3WindMap = new D3WindMap({
            div: elementsLayer.getDiv(),
            map: map,
            d3Layer: elementsLayer
        });
    }

    function addWindMap() {

        myD3WindMap.addData(windData);
    }

    function setData() {
        windData = xiamenWind1.concat(xiamenWind2);
    }
    function clear1() {
        myD3WindMap.clear();
    }
    function stop() {
        myD3WindMap.stop();
    }
    function run() {
        myD3WindMap.run();
    }
</script>
</body>
</html>
